/*
 * GameWorld.h
 *
 *  Created on: Jan 3, 2009
 *      Author: Carmine Red
 */

#ifndef GAMEWORLD_H_
#define GAMEWORLD_H_

#include "Prismatic.h"
class Prismatic;

#include "DirTile.h"

#include "AnchorPoint.h"
#include "LightFence.h"
#include "Enemy.h"

#include "Defines.h"

#include <list>			// for easy lists

class GameWorld
{
private:
	// LIST OF ANCHORPOINTS
	std::list<AnchorPoint>	listAnchor;

	// LIST OF LIGHTFENCES
	std::list<LightFence>	listFences;

	// LIST OF ENEMIES
	std::list<Enemy>	listEnemies;

	// test enemy
	Enemy test;

	// Tiles tall
	int rows;

	// Tiles across
	int cols;

	// 2D Directional Tile Array
	DirTile ** dirTileArray;

	// collision array for the tiles
	//	this array is used for testing for infinite direction loops
	bool ** collisionArray;

	// entrance set...
	bool entranceSet;

	// entrance Tile
	DirTile entranceTile;

	// first Tile info
	//	this x and y indicates the first tile the enemies enter, regardless of whether
	// it's activated or not.
	//	this means that we can trace their path through the tiles, starting with this
	// tile and the entranceTile direction.
	int firstTileX;
	int firstTileY;

	// RESULTING LEVEL WIDTH
	float levelWidth;

	// RESULTING LEVEL HEIGHT
	float levelHeight;

public:
	GameWorld();
	~GameWorld();

	bool loadLevel();	// loads a new level into the world, will take input later

	void update(Prismatic* game);		// this update handles a lot of stuff

	void render(Prismatic* game);

	bool getRelevantTile(float xUse, float yUse, int &xInd, int &yInd);		// returns the indices
															// to the DirTile being pointed at

	void setEntranceTile(float xUse, float yUse);	// sets entranceTile info
	void confirmEntranceTile();					// sets entranceTileInfo in stone
	bool isOutOfLevel(float xUse, float yUse);		// returns true if an enemy is out of level
										// which is defined as being further than
										// levelWidth or levelHeight divided by 2
										// plus offset
										//		this distance is greater than the one they
										// spawn at

	bool incrementDirTileDir(int xIndex, int yIndex);	// increments dirtile direction
										//	but also makes sure it doesn't result in an
										// infinite loop(tile pointing at previously used tile,
										// incrementing the direction several times if need be,
										// returns false if no direction found

	void processInput(Prismatic* game);
};

#endif /* GAMEWORLD_H_ */
